$(document).ready( function(){
	
	// Facebook integration
	(function(d, s, id) {
		var js, fjs = d.getElementsByTagName(s)[0];
		if (d.getElementById(id)) {return;}
		js = d.createElement(s); js.id = id;
		js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
		fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));
	
	

	var alertHeight = $('#alertArrowKeys').height();
	var alertWidth = $('#alertArrowKeys').width();
	$('#alertArrowKeys').css("width",alertWidth+80+"px");
	$('#alertArrowKeys').css("top", $(window).height()/2-alertHeight/2+"px");
	$('#alertArrowKeys').css("left", ($(window).width()/2)-(alertWidth/2)-40+"px");

	var fullScreenApi = {
		supportsFullScreen: false,
		isFullScreen: function() { return false; },
		requestFullScreen: function() {},
		cancelFullScreen: function() {},
		fullScreenEventName: '',
		prefix: ''
		},
		browserPrefixes = 'webkit moz o ms khtml'.split(' ');	
	
	// check for native support
	if (typeof document.cancelFullScreen != 'undefined') {
		//fullScreenApi.supportsFullScreen = true;
	} else {
		// check for fullscreen support by vendor prefix
		for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
			fullScreenApi.prefix = browserPrefixes[i];

			if (typeof document[fullScreenApi.prefix + 'CancelFullScreen' ] != 'undefined' ) {
				// Fullscreen support
				break;
			} else {
				// Ingen fullscreen support
				$('footer img').hide();
				break;
			}
	    }
	}
	
});
		
$(window).load( function() {
	$('#alertArrowKeys').delay(1000).fadeTo('slow', 0.85).delay(3000).fadeOut('slow');
});

$('header img#logo').click(function() {
//	$('header nav').slideToggle('slow', function() {
	    // Animation complete.
//	  });
});
	
$('nav img#fullscreen').click(function() {
	if (document.webkitIsFullScreen != 'undefined'){
		if(document.webkitIsFullScreen){
			document.webkitCancelFullScreen();	
		} else {
			document.body.webkitRequestFullScreen();
			//$(document).css('position', 'fixed').css('width', '100%').css('height', '100%');
			//$(document).focus();
			//$('button').hide();	
		}
	} else {
		alert('Browser not supported. You need to install the latest WebKit (for example Chrome 15) in order to use the full-screen API.');
	}
});

// Google analytics

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18175888-1']);
_gaq.push(['_setDomainName', '.nicolajroos.dk']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); 
	ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  	var s = document.getElementsByTagName('script')[0]; 
	s.parentNode.insertBefore(ga, s);
})();

